//
//  RewardHeadView.m
//  Base_App
//
//  Created by Yutian Duan on 2019/6/2.
//  Copyright © 2019年 Wanwin. All rights reserved.
//

#import "RewardHeadView.h"
#import "LineProgressView.h"

@interface RewardHeadView ()

@property (nonatomic, strong) UIImageView *bgImageView;
///! title
@property (nonatomic, strong) UILabel *titleLabel;


@property (nonatomic, strong) UIView *isLoginView;
@property (nonatomic, strong) UILabel *scoreLabel;
@property (nonatomic, strong) LineProgressView *progressView;
@property (nonatomic, strong) UILabel *progressLabel;

@end

@implementation RewardHeadView

- (UIView *)isLoginView {
  if (!_isLoginView) {
    _isLoginView = [[UIView alloc] initWithFrame:CGRectMake(0, _titleLabel.yt_bottom, ScreenWidth, self.yt_height - _titleLabel.yt_bottom)];
    [self addSubview:_isLoginView];
    
    UILabel *tipLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, _isLoginView.yt_width, 18)];
    tipLabel.text = [NSString stringWithFormat:@"%@：",YTLocalizedString(@"可兑换积分")];
    tipLabel.textColor = DEF_GRAY;
    tipLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:15.0f];
    tipLabel.textAlignment = NSTextAlignmentLeft;
    [_isLoginView addSubview:tipLabel];
    
    ///!
    _scoreLabel = [[UILabel alloc] initWithFrame:CGRectMake(tipLabel.yt_left, tipLabel.yt_bottom, tipLabel.yt_width, 30)];
    _scoreLabel.textColor = DEF_BLACK;
    _scoreLabel.textAlignment = NSTextAlignmentLeft;
    _scoreLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:18.0f];
    [_isLoginView addSubview:_scoreLabel];
    
    ///
    UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(_scoreLabel.yt_left, _scoreLabel.yt_bottom, _scoreLabel.yt_width, 13)];
    noteLabel.textColor = DEF_BLACK;
    noteLabel.textAlignment = NSTextAlignmentLeft;
    noteLabel.text = YTLocalizedString(@"累积达指定积分可升级会员等级(兑换后不扣减)");
    noteLabel.font = [UIFont systemFontOfSize:11];
    [_isLoginView addSubview:noteLabel];
    
    _progressView = [[LineProgressView alloc] initWithFrame:CGRectMake(noteLabel.yt_left, noteLabel.yt_bottom + 5, _isLoginView.yt_width - noteLabel.yt_left - 80, 5)];
    [_isLoginView addSubview:_progressView];

    _progressLabel = [[UILabel alloc] initWithFrame:CGRectMake(_progressView.yt_right + 3, 0, 50, 20)];
    _progressLabel.textColor = DEF_RED;
    _progressLabel.font = [UIFont systemFontOfSize:13];
    _progressLabel.textAlignment = NSTextAlignmentLeft;
    [_isLoginView addSubview:_progressLabel];
    _progressLabel.yt_centerY = _progressView.yt_centerY;
  

    
  }
  return _isLoginView;
}

- (instancetype)initWithFrame:(CGRect)frame {
  self = [super initWithFrame:frame];
  if (self) {
    self.backgroundColor = HEXCOLOR(0xf7f8fc);
    [self createViews];
  }
  return self;
}

- (void)createViews {
  
  _bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.yt_width, self.yt_height)];
  _bgImageView.clipsToBounds = YES;
//  _bgImageView.contentMode = UIViewContentModeScaleAspectFill;
//  _bgImageView.image = [UIImage imageNamed:@"Oil_head_login"];
  [self addSubview:_bgImageView];


  //！
  _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 120, 40)];
  _titleLabel.text = YTLocalizedString(@"奖赏");
  _titleLabel.textColor = [UIColor blackColor];
  _titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:20.0f];
  [_bgImageView addSubview:_titleLabel];

  CGFloat logoH = 13;
  if (IS_IPHONE5) {
    logoH = 10;
  }
  
  //! logo
  UIImageView *logoView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, logoH * 14, logoH)];
  logoView.image = [UIImage imageNamed:@"Setting_logo"];
  logoView.contentMode = UIViewContentModeScaleAspectFit;
  [_bgImageView addSubview:logoView];
  logoView.yt_centerY = _titleLabel.yt_centerY;
  logoView.yt_right = _bgImageView.yt_right - 20;

  
  self.isLoginView.hidden = NO;
  _scoreLabel.text = @"300,250pt.";
  _progressView.progress = 112/150.0;
  _progressLabel.text = @"112/150";

}

@end
